package com.kanshu.ksgb.fastread.doudou.module.bookcity.adapter;

import android.content.Context;
import android.widget.LinearLayout;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;
import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.common.imageloader.GlideImageLoader;
import com.kanshu.ksgb.fastread.doudou.common.util.DisplayUtils;
import com.kanshu.ksgb.fastread.doudou.common.business.commonbean.BookInfo;

import java.util.List;

/**
 * 专题适配器
 * Created by wcy on 18/5/24.
 */
public class TopicAdapter extends BaseQuickAdapter<BookInfo> {

    public TopicAdapter(Context context, List<BookInfo> data) {
        super(context, data);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_topic_all_layout;
    }

    @Override
    protected void convert(BaseViewHolder holder, BookInfo item, int position) {
        holder.setText(R.id.desc, item.title);
        GlideImageLoader.load(item.title_big_img, holder.getView(R.id.cover), GlideImageLoader.getEmptyConfig());
        LinearLayout root = holder.getView(R.id.root_container);
        position = position - getHeaderViewsCount();
        if (position % 2 == 0) {
            root.setPadding(DisplayUtils.dip2px(mContext, 14), 0, 0,0 );
        } else {
            root.setPadding(0, 0, DisplayUtils.dip2px(mContext, 14),0 );
        }
    }
}
